package com.medical.admin.cost.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.medical.admin.cost.common.dto.OutpatientInfo;
import com.medical.admin.cost.service.OutpatientConsumptionService;
import com.qf.medical.response.ResponseEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * 1.条件动态查询门诊消费记录
 * 2.增加门诊消费记录
 * 3.删除门诊消费记录
 * 4.修改门诊消费记录
 * 5.查看门诊消费详细记录
 */
@Api(tags = "后台门诊消费管理API在线接口文档")
@RestController
@RequestMapping("/outpatient/consumption")
public class OutpatientConsumptionController {
    @Resource
    private OutpatientConsumptionService outpatientConsumptionService;

    @ApiOperation("动态分页查询消费记录")
    @PostMapping("/searchList/{page}/{size}")
    @ApiImplicitParams({@ApiImplicitParam(name = "outpatientInfo",value = "dto参数实体类"),
    @ApiImplicitParam(name = "page",value = "页码"),@ApiImplicitParam(name = "size",value = "条数")})
    public ResponseEntity<IPage<OutpatientInfo>> searchList(@NotNull @RequestBody OutpatientInfo outpatientInfo,
                                                            @RequestParam(name = "page",defaultValue = "1")@PathVariable("page") Integer page,
                                                            @RequestParam(name = "size",defaultValue = "10") @PathVariable("size") Integer size){
        return ResponseEntity.success(outpatientConsumptionService.searchOutpatientList(outpatientInfo,page,size));
    }

    @ApiOperation("消费信息添加")
    @PostMapping("/addOutpatient")
    @ApiImplicitParam(name = "outpatientInfo",value = "dto参数实体类")
    public ResponseEntity<Integer> addOutpatient(@NotNull @RequestBody OutpatientInfo outpatientInfo){
        return ResponseEntity.success(outpatientConsumptionService.addOutpatient(outpatientInfo));
    }

    @ApiOperation("消费信息删除")
    @DeleteMapping("/removeOutpatient")
    @ApiImplicitParam(name = "indentId",value = "订单id")
    public ResponseEntity<Integer> removeOutpatient(@NotNull Long indentId){
        return ResponseEntity.success(outpatientConsumptionService.removeOutpatient(indentId));
    }

    @ApiOperation("修改消费信息")
    @PutMapping("/modifyOutpatient")
    @ApiImplicitParam(name = "OutpatientInfo",value = "dto参数实体类")
    public ResponseEntity<Integer> modifyOutpatient(@NotNull @RequestBody OutpatientInfo outpatientInfo){
        return ResponseEntity.success(outpatientConsumptionService.modifyOutpatient(outpatientInfo));
    }

    @ApiOperation("查询消费详细信息")
    @GetMapping("/detailOutpatient")
    @ApiImplicitParam(name = "indentId",value = "订单id")
    public ResponseEntity<OutpatientInfo> detailOutpatient(@NotNull  Long indentId){
        return ResponseEntity.success(outpatientConsumptionService.detailOutpatient(indentId));
    }
}
